﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PInitiatives.Outlook
{
    public class ObservableSubject
    {
        public List<Observer> observers;//Subject can have more than one observer

        public ObservableSubject()
        {
            observers = new List<Observer>();
        }

       public void AddObserver(Observer observer)
        {
            this.observers.Add(observer);
        }

        void RemoveObserver(Observer observer)
        {
            this.observers.Remove(observer);
        }

        //inform all observers about change of own state
        public void Notify()
        {
            foreach (Observer o in observers)
            {
                o.Update();
            }
        }
    }
}